package com.ebraga.trackerclub.android.manager.core;

import com.ebraga.trackerclub.android.dao.api.ParameterDao;
import com.ebraga.trackerclub.android.dao.entity.ParameterAndroid;
import com.ebraga.trackerclub.android.exception.BackofficeDBConnectionException;
import com.ebraga.trackerclub.android.exception.dao.BackofficeDaoException;
import com.ebraga.trackerclub.android.exception.manager.BackofficeIllegalArgumentManagerException;
import com.ebraga.trackerclub.android.exception.manager.BackofficeManagerException;
import com.ebraga.trackerclub.android.manager.api.ParameterManager;
import com.ebraga.trackerclub.android.util.DLog;

public abstract class ParameterManagerImpl implements ParameterManager {
	
	protected ParameterDao  parameterDao;
	
	protected void setParameterDao (ParameterDao  parameterDao){
		this.parameterDao = parameterDao;
	}

	public ParameterAndroid getParameter(String param)
			throws BackofficeIllegalArgumentManagerException,
			BackofficeDBConnectionException,
			BackofficeManagerException {
		
		ParameterAndroid parameterAndroid = null;
		
		try{
			parameterAndroid = parameterDao.getParameter(param);
			
			return parameterAndroid;
			
		}catch(BackofficeDBConnectionException db){
			DLog.e(db);
			throw new BackofficeDBConnectionException ("Erro ao conectar banco de dados");
		}catch(BackofficeDaoException e){
			DLog.e(e);
			throw new BackofficeManagerException (e.getMessage());
		}
		
		
	}


}
